#!/usr/bin/python
# -*- coding: UTF-8 -*-  

"TestProperty"

__author__ = "Wang Zhe"

class Student(object):
    """docstring for Student"""
    _score = 0
    _birth = 0

    def __init__(self):
        super(Student, self).__init__()
        
    @property
    def score(self):
        return self._score

    @score.setter
    def score(self,value):
        if not isinstance(value,int):
            raise ValueError('score must be an interger!')
        if value < 0 or value > 100:
            raise ValueError('score must between 0 ~ 100!')
        self._score = value

    @property
    def birth(self):
        return self._birth

    @birth.setter
    def birth(self,value):
        self._birth = value

    @property
    def age(self):
        return 2017- self._birth

class Screen(object):
    """docstring for Screen"""
    _width = 0
    _height = 0

    def __init__(self):
        super(Screen, self).__init__()
    
    @property
    def width(self):
        return self._width

    @width.setter
    def width(self,value):
        self._width = value

    @property
    def height(self):
        return self._height

    @height.setter
    def height(self,value):
        self._height = value

    # @property 
    # def resolution(self):
    #     return "%s x %s" %(self.width,self.height)
        
    @property 
    def resolution(self):
        return self.width * self.height

def main():
    s = Student()
    s.score = 99
    print(s.score)
    s.birth = 1992
    print(s.age)

    s = Screen()
    s.width = 1024
    s.height = 768
    print(s.resolution)

    assert s.resolution == 786432 , 'resolution:%d' %s.resolution

if __name__ == '__main__':
    main()